{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "pwsh"
    },
    "vscode": {
     "languageId": "dotnet-interactive.pwsh"
    }
   },
   "outputs": [],
   "source": [
    "#!pwsh\n",
    "dotnet build -c release\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "vscode": {
     "languageId": "dotnet-interactive.fsharp"
    }
   },
   "outputs": [],
   "source": [
    "#r \"../../../artifacts/bin/FSharp.Compiler.Benchmarks/Release/net7.0/FSharp.Compiler.Benchmarks.dll\"\n",
    "#r \"../../../artifacts/bin/FSharp.Compiler.Benchmarks/Release/net7.0/BenchmarkDotNet.dll\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "vscode": {
     "languageId": "dotnet-interactive.fsharp"
    }
   },
   "outputs": [],
   "source": [
    "open BenchmarkDotNet.Running\n",
    "open FSharp.Compiler.Benchmarks\n",
    "\n",
    "let summary = BenchmarkRunner.Run<TypeCheckingBenchmark1>()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "vscode": {
     "languageId": "dotnet-interactive.fsharp"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><div></div><div></div><div></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\r\n",
       "<div style=\"width: 900px; height: 500px;\" id=\"163f19ca-77b0-427f-9b32-cf9bb001d3da\"></div><script type=\"text/javascript\">\r\n",
       "\n",
       "var renderPlotly = function() {\n",
       "    var xplotRequire = require.config({context:'xplot-3.0.1',paths:{plotly:'https://cdn.plot.ly/plotly-1.49.2.min'}}) || require;\n",
       "    xplotRequire(['plotly'], function(Plotly) { \r\n",
       "\n",
       "            var data = [{\"type\":\"bar\",\"y\":[15],\"name\":\"Gen 0\"},{\"type\":\"bar\",\"y\":[8],\"name\":\"Gen 1\"},{\"type\":\"bar\",\"y\":[5],\"name\":\"Gen 2\"}];\n",
       "           var layout = {\"title\":\"F# Type-Checking Benchmark 1 - GC Collection Counts\"};\n",
       "           Plotly.newPlot('163f19ca-77b0-427f-9b32-cf9bb001d3da', data, layout);\n",
       "        \r\n",
       "});\n",
       "};\r\n",
       "// ensure `require` is available globally\r\n",
       "if ((typeof(require) !==  typeof(Function)) || (typeof(require.config) !== typeof(Function))) {\r\n",
       "    let require_script = document.createElement('script');\r\n",
       "    require_script.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js');\r\n",
       "    require_script.setAttribute('type', 'text/javascript');\r\n",
       "    \r\n",
       "    \r\n",
       "    require_script.onload = function() {\r\n",
       "        renderPlotly();\r\n",
       "    };\r\n",
       "\r\n",
       "    document.getElementsByTagName('head')[0].appendChild(require_script);\r\n",
       "}\r\n",
       "else {\r\n",
       "    renderPlotly();\r\n",
       "}\r\n",
       "\r\n",
       "</script>\r\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "// https://benchmarkdotnet.org/api/BenchmarkDotNet.Reports.BenchmarkReport.html\n",
    "#r \"nuget: XPlot.Plotly.Interactive, 4.0.2\"\n",
    "\n",
    "open XPlot.Plotly\n",
    "\n",
    "let gcStats = summary.Reports |> Seq.map (fun x -> x.GcStats)\n",
    "\n",
    "let gen0Series =\n",
    "    Bar(\n",
    "        name = \"Gen 0\",\n",
    "        y = (gcStats |> Seq.map (fun x -> x.Gen0Collections))\n",
    "    )\n",
    "\n",
    "let gen1Series =\n",
    "    Bar(\n",
    "        name = \"Gen 1\",\n",
    "        y = (gcStats |> Seq.map (fun x -> x.Gen1Collections))\n",
    "    )\n",
    "\n",
    "let gen2Series =\n",
    "    Bar(\n",
    "        name = \"Gen 2\",\n",
    "        y = (gcStats |> Seq.map (fun x -> x.Gen2Collections))\n",
    "    )\n",
    "\n",
    "[gen0Series;gen1Series;gen2Series]\n",
    "|> Chart.Plot\n",
    "|> Chart.WithTitle(\"F# Type-Checking Benchmark 1 - GC Collection Counts\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "C#",
   "pygments_lexer": "csharp",
   "version": "9.0"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
